﻿///----------------------------------------------------------------
/// Copyright (C) 2008-2010 yyssoft
/// 版权所有。
///
/// 文件名：TB_DJSKCBDAL.cs
/// 文件功能描述：TB_DJSKCB数据访问类
///
///
/// 创建标识：yyssoft 2013/11/5
///
/// 修改标识：
/// 修改描述：
///
/// 修改标识：
/// 修改描述：
///---------------------------------------------------------------
using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using DQYT.HTDZ.Model;
using Maticsoft.DBUtility;
using System.Data.OracleClient;
using DQYT.HTDZ.IDAL;

namespace DQYT.HTDZ.OracleDAL
{
    /// <summary>
    /// TB_DJSKCB的数据访问类
    /// </summary>
    public class TB_DJSKCBDAL : ITB_DJSKCBDAL
    {

        #region  构造函数

        public TB_DJSKCBDAL()
        { }

        #endregion  构造函数

        #region  成员方法

        /// <summary>
        /// 获取最大ID
        /// </summary>
        /// <returns>最大ID</returns>
        public DataSet getMaxID()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"SELECT MAX(ID) as maxid FROM TB_DJSKCB ");
            return DbHelperOra.Query(strSql.ToString());
        }


        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string JH)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from TB_DJSKCB");
            strSql.Append(" where JH=:JH ");
            OracleParameter[] parameters = {
					new OracleParameter(":JH", OracleType.VarChar,150)			};
            parameters[0].Value = JH;

            return DbHelperOra.Exists(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回主标识ID,失败返回"0"</returns>
        public bool AddBySql(TB_DJSKCBInfo model)
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append(@" INSERT INTO TB_DJSKCB 
					(ID,JH,SJRQ,SGFS,LX,JS,XM,DX,QX,ZYLQX,FHLX,JSLX,DJSR,SKHD,DS,DDJ,DJE,DJESZ,QC,QDJ,QC2,QDJ2,QJE,QJESZ,JCQC,JCQDJ,JCQJE,QDHJJE,JCQJESZ,BZQCDJXH,YBCLDJXH,PTYBCL,DJCLCB,GDFY,ZJF,QTBDFY,DJCB,YY,JDDS,JDDS1,JD,JDSK,SKHD2,CLLTF) 
					VALUES(:ID,:JH,:SJRQ,:SGFS,:LX,:JS,:XM,:DX,:QX,:ZYLQX,:FHLX,:JSLX,:DJSR,:SKHD,:DS,:DDJ,:DJE,:DJESZ,:QC,:QDJ,:QC2,:QDJ2,:QJE,:QJESZ,:JCQC,:JCQDJ,:JCQJE,:QDHJJE,:JCQJESZ,:BZQCDJXH,:YBCLDJXH,:PTYBCL,:DJCLCB,:GDFY,:ZJF,:QTBDFY,:DJCB,:YY,:JDDS,:JDDS1,:JD,:JDSK,:SKHD2,:CLLTF)");
            

            OracleParameter[] parameters = {
					new OracleParameter(":"+TB_DJSKCBInfo.ID_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JH_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.SJRQ_FIELD, OracleType.DateTime),
					new OracleParameter(":"+TB_DJSKCBInfo.SGFS_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.LX_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.JS_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.XM_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.DX_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.QX_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.ZYLQX_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.FHLX_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.JSLX_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.DJSR_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.SKHD_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.DS_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.DDJ_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.DJE_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.DJESZ_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QC_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QDJ_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QC2_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QDJ2_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QJE_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QJESZ_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JCQC_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JCQDJ_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JCQJE_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QDHJJE_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JCQJESZ_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.BZQCDJXH_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.YBCLDJXH_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.PTYBCL_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.DJCLCB_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.GDFY_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.ZJF_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QTBDFY_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.DJCB_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.YY_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JDDS_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JDDS1_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JD_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JDSK_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.SKHD2_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.CLLTF_FIELD, OracleType.Number,8)};
            parameters[0].Value = model.ID;
            parameters[1].Value = model.JH;
            parameters[2].Value = model.SJRQ == Convert.ToDateTime("1900-1-1") ? DBNull.Value : (object)model.SJRQ;
            parameters[3].Value = model.SGFS;
            parameters[4].Value = model.LX;
            parameters[5].Value = model.JS == int.MinValue ? DBNull.Value : (object)model.JS;
            parameters[6].Value = model.XM;
            parameters[7].Value = model.DX;
            parameters[8].Value = model.QX;
            parameters[9].Value = model.ZYLQX;
            parameters[10].Value = model.FHLX;
            parameters[11].Value = model.JSLX;
            parameters[12].Value = model.DJSR == int.MinValue ? DBNull.Value : (object)model.DJSR;
            parameters[13].Value = model.SKHD == int.MinValue ? DBNull.Value : (object)model.SKHD;
            parameters[14].Value = model.DS == int.MinValue ? DBNull.Value : (object)model.DS;
            parameters[15].Value = model.DDJ == int.MinValue ? DBNull.Value : (object)model.DDJ;
            parameters[16].Value = model.DJE == int.MinValue ? DBNull.Value : (object)model.DJE;
            parameters[17].Value = model.DJESZ == int.MinValue ? DBNull.Value : (object)model.DJESZ;
            parameters[18].Value = model.QC == int.MinValue ? DBNull.Value : (object)model.QC;
            parameters[19].Value = model.QDJ == int.MinValue ? DBNull.Value : (object)model.QDJ;
            parameters[20].Value = model.QC2 == int.MinValue ? DBNull.Value : (object)model.QC2;
            parameters[21].Value = model.QDJ2 == int.MinValue ? DBNull.Value : (object)model.QDJ2;
            parameters[22].Value = model.QJE == int.MinValue ? DBNull.Value : (object)model.QJE;
            parameters[23].Value = model.QJESZ == int.MinValue ? DBNull.Value : (object)model.QJESZ;
            parameters[24].Value = model.JCQC == int.MinValue ? DBNull.Value : (object)model.JCQC;
            parameters[25].Value = model.JCQDJ == int.MinValue ? DBNull.Value : (object)model.JCQDJ;
            parameters[26].Value = model.JCQJE == int.MinValue ? DBNull.Value : (object)model.JCQJE;
            parameters[27].Value = model.QDHJJE == int.MinValue ? DBNull.Value : (object)model.QDHJJE;
            parameters[28].Value = model.JCQJESZ == int.MinValue ? DBNull.Value : (object)model.JCQJESZ;
            parameters[29].Value = model.BZQCDJXH == int.MinValue ? DBNull.Value : (object)model.BZQCDJXH;
            parameters[30].Value = model.YBCLDJXH == int.MinValue ? DBNull.Value : (object)model.YBCLDJXH;
            parameters[31].Value = model.PTYBCL == int.MinValue ? DBNull.Value : (object)model.PTYBCL;
            parameters[32].Value = model.DJCLCB == int.MinValue ? DBNull.Value : (object)model.DJCLCB;
            parameters[33].Value = model.GDFY == int.MinValue ? DBNull.Value : (object)model.GDFY;
            parameters[34].Value = model.ZJF == int.MinValue ? DBNull.Value : (object)model.ZJF;
            parameters[35].Value = model.QTBDFY == int.MinValue ? DBNull.Value : (object)model.QTBDFY;
            parameters[36].Value = model.DJCB == int.MinValue ? DBNull.Value : (object)model.DJCB;
            parameters[37].Value = model.YY == int.MinValue ? DBNull.Value : (object)model.YY;
            parameters[38].Value = model.JDDS == int.MinValue ? DBNull.Value : (object)model.JDDS;
            parameters[39].Value = model.JDDS1 == int.MinValue ? DBNull.Value : (object)model.JDDS1;
            parameters[40].Value = model.JD == int.MinValue ? DBNull.Value : (object)model.JD;
            parameters[41].Value = model.JDSK == int.MinValue ? DBNull.Value : (object)model.JDSK;
            parameters[42].Value = model.SKHD2 == int.MinValue ? DBNull.Value : (object)model.SKHD2;
            parameters[43].Value = model.CLLTF == int.MinValue ? DBNull.Value : (object)model.CLLTF;

            int rows=DbHelperOra.ExecuteSql(sbSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回"1",失败返回"0"</returns>
        public bool UpdateBySql(TB_DJSKCBInfo model)
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append(@" UPDATE TB_DJSKCB 
					SET JH = :JH,SJRQ = :SJRQ,SGFS = :SGFS,LX = :LX,JS = :JS,XM = :XM,DX = :DX,QX = :QX,ZYLQX = :ZYLQX,FHLX = :FHLX,JSLX = :JSLX,DJSR = :DJSR,SKHD = :SKHD,DS = :DS,DDJ = :DDJ,DJE = :DJE,DJESZ = :DJESZ,QC = :QC,QDJ = :QDJ,QC2 = :QC2,QDJ2 = :QDJ2,QJE = :QJE,QJESZ = :QJESZ,JCQC = :JCQC,JCQDJ = :JCQDJ,JCQJE = :JCQJE,QDHJJE = :QDHJJE,JCQJESZ = :JCQJESZ,BZQCDJXH = :BZQCDJXH,YBCLDJXH = :YBCLDJXH,PTYBCL = :PTYBCL,DJCLCB = :DJCLCB,GDFY = :GDFY,ZJF = :ZJF,QTBDFY = :QTBDFY,DJCB = :DJCB,YY = :YY,JDDS = :JDDS,JDDS1 = :JDDS1,JD = :JD,JDSK = :JDSK,SKHD2 = :SKHD2,CLLTF = :CLLTF 
					WHERE ID=:ID ");

            OracleParameter[] parameters = {
					new OracleParameter(":"+TB_DJSKCBInfo.ID_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JH_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.SJRQ_FIELD, OracleType.DateTime),
					new OracleParameter(":"+TB_DJSKCBInfo.SGFS_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.LX_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.JS_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.XM_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.DX_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.QX_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.ZYLQX_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.FHLX_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.JSLX_FIELD, OracleType.VarChar,150),
					new OracleParameter(":"+TB_DJSKCBInfo.DJSR_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.SKHD_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.DS_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.DDJ_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.DJE_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.DJESZ_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QC_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QDJ_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QC2_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QDJ2_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QJE_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QJESZ_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JCQC_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JCQDJ_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JCQJE_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QDHJJE_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JCQJESZ_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.BZQCDJXH_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.YBCLDJXH_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.PTYBCL_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.DJCLCB_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.GDFY_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.ZJF_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.QTBDFY_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.DJCB_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.YY_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JDDS_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JDDS1_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JD_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.JDSK_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.SKHD2_FIELD, OracleType.Number,8),
					new OracleParameter(":"+TB_DJSKCBInfo.CLLTF_FIELD, OracleType.Number,8)};
            parameters[0].Value = model.ID;
            parameters[1].Value = model.JH;
            parameters[2].Value = model.SJRQ == Convert.ToDateTime("1900-1-1") ? DBNull.Value : (object)model.SJRQ;
            parameters[3].Value = model.SGFS;
            parameters[4].Value = model.LX;
            parameters[5].Value = model.JS == int.MinValue ? DBNull.Value : (object)model.JS;
            parameters[6].Value = model.XM;
            parameters[7].Value = model.DX;
            parameters[8].Value = model.QX;
            parameters[9].Value = model.ZYLQX;
            parameters[10].Value = model.FHLX;
            parameters[11].Value = model.JSLX;
            parameters[12].Value = model.DJSR == int.MinValue ? DBNull.Value : (object)model.DJSR;
            parameters[13].Value = model.SKHD == int.MinValue ? DBNull.Value : (object)model.SKHD;
            parameters[14].Value = model.DS == int.MinValue ? DBNull.Value : (object)model.DS;
            parameters[15].Value = model.DDJ == int.MinValue ? DBNull.Value : (object)model.DDJ;
            parameters[16].Value = model.DJE == int.MinValue ? DBNull.Value : (object)model.DJE;
            parameters[17].Value = model.DJESZ == int.MinValue ? DBNull.Value : (object)model.DJESZ;
            parameters[18].Value = model.QC == int.MinValue ? DBNull.Value : (object)model.QC;
            parameters[19].Value = model.QDJ == int.MinValue ? DBNull.Value : (object)model.QDJ;
            parameters[20].Value = model.QC2 == int.MinValue ? DBNull.Value : (object)model.QC2;
            parameters[21].Value = model.QDJ2 == int.MinValue ? DBNull.Value : (object)model.QDJ2;
            parameters[22].Value = model.QJE == int.MinValue ? DBNull.Value : (object)model.QJE;
            parameters[23].Value = model.QJESZ == int.MinValue ? DBNull.Value : (object)model.QJESZ;
            parameters[24].Value = model.JCQC == int.MinValue ? DBNull.Value : (object)model.JCQC;
            parameters[25].Value = model.JCQDJ == int.MinValue ? DBNull.Value : (object)model.JCQDJ;
            parameters[26].Value = model.JCQJE == int.MinValue ? DBNull.Value : (object)model.JCQJE;
            parameters[27].Value = model.QDHJJE == int.MinValue ? DBNull.Value : (object)model.QDHJJE;
            parameters[28].Value = model.JCQJESZ == int.MinValue ? DBNull.Value : (object)model.JCQJESZ;
            parameters[29].Value = model.BZQCDJXH == int.MinValue ? DBNull.Value : (object)model.BZQCDJXH;
            parameters[30].Value = model.YBCLDJXH == int.MinValue ? DBNull.Value : (object)model.YBCLDJXH;
            parameters[31].Value = model.PTYBCL == int.MinValue ? DBNull.Value : (object)model.PTYBCL;
            parameters[32].Value = model.DJCLCB == int.MinValue ? DBNull.Value : (object)model.DJCLCB;
            parameters[33].Value = model.GDFY == int.MinValue ? DBNull.Value : (object)model.GDFY;
            parameters[34].Value = model.ZJF == int.MinValue ? DBNull.Value : (object)model.ZJF;
            parameters[35].Value = model.QTBDFY == int.MinValue ? DBNull.Value : (object)model.QTBDFY;
            parameters[36].Value = model.DJCB == int.MinValue ? DBNull.Value : (object)model.DJCB;
            parameters[37].Value = model.YY == int.MinValue ? DBNull.Value : (object)model.YY;
            parameters[38].Value = model.JDDS == int.MinValue ? DBNull.Value : (object)model.JDDS;
            parameters[39].Value = model.JDDS1 == int.MinValue ? DBNull.Value : (object)model.JDDS1;
            parameters[40].Value = model.JD == int.MinValue ? DBNull.Value : (object)model.JD;
            parameters[41].Value = model.JDSK == int.MinValue ? DBNull.Value : (object)model.JDSK;
            parameters[42].Value = model.SKHD2 == int.MinValue ? DBNull.Value : (object)model.SKHD2;
            parameters[43].Value = model.CLLTF == int.MinValue ? DBNull.Value : (object)model.CLLTF;

            int rows=DbHelperOra.ExecuteSql(sbSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回"1",失败返回"0"</returns>
        public bool DeleteBySql(int ID)
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append(@" DELETE TB_DJSKCB 
					WHERE ID=:ID ");

            OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,8)};
            parameters[0].Value = ID;

            int rows = DbHelperOra.ExecuteSql(sbSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TB_DJSKCBInfo GetModelBySql(int ID)
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append(@"SELECT ID,JH,SJRQ,SGFS,LX,JS,XM,DX,QX,ZYLQX,FHLX,JSLX,DJSR,SKHD,DS,DDJ,DJE,DJESZ,QC,QDJ,QC2,QDJ2,QJE,QJESZ,JCQC,JCQDJ,JCQJE,QDHJJE,JCQJESZ,BZQCDJXH,YBCLDJXH,PTYBCL,DJCLCB,GDFY,ZJF,QTBDFY,DJCB,YY,JDDS,JDDS1,JD,JDSK,SKHD2,CLLTF 
					FROM TB_DJSKCB
					WHERE ID=:ID ");

            OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,8)};
            parameters[0].Value = ID;

            TB_DJSKCBInfo model = new TB_DJSKCBInfo();
            DataSet ds = DbHelperOra.Query(sbSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["JH"] != null && ds.Tables[0].Rows[0]["JH"].ToString() != "")
                {
                    model.JH = ds.Tables[0].Rows[0]["JH"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SJRQ"] != null && ds.Tables[0].Rows[0]["SJRQ"].ToString() != "")
                {
                    model.SJRQ = Convert.ToDateTime(ds.Tables[0].Rows[0]["SJRQ"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SGFS"] != null && ds.Tables[0].Rows[0]["SGFS"].ToString() != "")
                {
                    model.SGFS = ds.Tables[0].Rows[0]["SGFS"].ToString();
                }
                if (ds.Tables[0].Rows[0]["LX"] != null && ds.Tables[0].Rows[0]["LX"].ToString() != "")
                {
                    model.LX = ds.Tables[0].Rows[0]["LX"].ToString();
                }
                if (ds.Tables[0].Rows[0]["JS"] != null && ds.Tables[0].Rows[0]["JS"].ToString() != "")
                {
                    model.JS = int.Parse(ds.Tables[0].Rows[0]["JS"].ToString());
                }
                if (ds.Tables[0].Rows[0]["XM"] != null && ds.Tables[0].Rows[0]["XM"].ToString() != "")
                {
                    model.XM = ds.Tables[0].Rows[0]["XM"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DX"] != null && ds.Tables[0].Rows[0]["DX"].ToString() != "")
                {
                    model.DX = ds.Tables[0].Rows[0]["DX"].ToString();
                }
                if (ds.Tables[0].Rows[0]["QX"] != null && ds.Tables[0].Rows[0]["QX"].ToString() != "")
                {
                    model.QX = ds.Tables[0].Rows[0]["QX"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ZYLQX"] != null && ds.Tables[0].Rows[0]["ZYLQX"].ToString() != "")
                {
                    model.ZYLQX = ds.Tables[0].Rows[0]["ZYLQX"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FHLX"] != null && ds.Tables[0].Rows[0]["FHLX"].ToString() != "")
                {
                    model.FHLX = ds.Tables[0].Rows[0]["FHLX"].ToString();
                }
                if (ds.Tables[0].Rows[0]["JSLX"] != null && ds.Tables[0].Rows[0]["JSLX"].ToString() != "")
                {
                    model.JSLX = ds.Tables[0].Rows[0]["JSLX"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DJSR"] != null && ds.Tables[0].Rows[0]["DJSR"].ToString() != "")
                {
                    model.DJSR = Convert.ToDecimal(ds.Tables[0].Rows[0]["DJSR"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SKHD"] != null && ds.Tables[0].Rows[0]["SKHD"].ToString() != "")
                {
                    model.SKHD = Convert.ToDecimal(ds.Tables[0].Rows[0]["SKHD"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DS"] != null && ds.Tables[0].Rows[0]["DS"].ToString() != "")
                {
                    model.DS = int.Parse(ds.Tables[0].Rows[0]["DS"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DDJ"] != null && ds.Tables[0].Rows[0]["DDJ"].ToString() != "")
                {
                    model.DDJ = Convert.ToDecimal(ds.Tables[0].Rows[0]["DDJ"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DJE"] != null && ds.Tables[0].Rows[0]["DJE"].ToString() != "")
                {
                    model.DJE = Convert.ToDecimal(ds.Tables[0].Rows[0]["DJE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DJESZ"] != null && ds.Tables[0].Rows[0]["DJESZ"].ToString() != "")
                {
                    model.DJESZ = Convert.ToDecimal(ds.Tables[0].Rows[0]["DJESZ"].ToString());
                }
                if (ds.Tables[0].Rows[0]["QC"] != null && ds.Tables[0].Rows[0]["QC"].ToString() != "")
                {
                    model.QC = Convert.ToDecimal(ds.Tables[0].Rows[0]["QC"].ToString());
                }
                if (ds.Tables[0].Rows[0]["QDJ"] != null && ds.Tables[0].Rows[0]["QDJ"].ToString() != "")
                {
                    model.QDJ = Convert.ToDecimal(ds.Tables[0].Rows[0]["QDJ"].ToString());
                }
                if (ds.Tables[0].Rows[0]["QC2"] != null && ds.Tables[0].Rows[0]["QC2"].ToString() != "")
                {
                    model.QC2 = Convert.ToDecimal(ds.Tables[0].Rows[0]["QC2"].ToString());
                }
                if (ds.Tables[0].Rows[0]["QDJ2"] != null && ds.Tables[0].Rows[0]["QDJ2"].ToString() != "")
                {
                    model.QDJ2 = Convert.ToDecimal(ds.Tables[0].Rows[0]["QDJ2"].ToString());
                }
                if (ds.Tables[0].Rows[0]["QJE"] != null && ds.Tables[0].Rows[0]["QJE"].ToString() != "")
                {
                    model.QJE = Convert.ToDecimal(ds.Tables[0].Rows[0]["QJE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["QJESZ"] != null && ds.Tables[0].Rows[0]["QJESZ"].ToString() != "")
                {
                    model.QJESZ = Convert.ToDecimal(ds.Tables[0].Rows[0]["QJESZ"].ToString());
                }
                if (ds.Tables[0].Rows[0]["JCQC"] != null && ds.Tables[0].Rows[0]["JCQC"].ToString() != "")
                {
                    model.JCQC = Convert.ToDecimal(ds.Tables[0].Rows[0]["JCQC"].ToString());
                }
                if (ds.Tables[0].Rows[0]["JCQDJ"] != null && ds.Tables[0].Rows[0]["JCQDJ"].ToString() != "")
                {
                    model.JCQDJ = Convert.ToDecimal(ds.Tables[0].Rows[0]["JCQDJ"].ToString());
                }
                if (ds.Tables[0].Rows[0]["JCQJE"] != null && ds.Tables[0].Rows[0]["JCQJE"].ToString() != "")
                {
                    model.JCQJE = Convert.ToDecimal(ds.Tables[0].Rows[0]["JCQJE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["QDHJJE"] != null && ds.Tables[0].Rows[0]["QDHJJE"].ToString() != "")
                {
                    model.QDHJJE = Convert.ToDecimal(ds.Tables[0].Rows[0]["QDHJJE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["JCQJESZ"] != null && ds.Tables[0].Rows[0]["JCQJESZ"].ToString() != "")
                {
                    model.JCQJESZ = Convert.ToDecimal(ds.Tables[0].Rows[0]["JCQJESZ"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BZQCDJXH"] != null && ds.Tables[0].Rows[0]["BZQCDJXH"].ToString() != "")
                {
                    model.BZQCDJXH = Convert.ToDecimal(ds.Tables[0].Rows[0]["BZQCDJXH"].ToString());
                }
                if (ds.Tables[0].Rows[0]["YBCLDJXH"] != null && ds.Tables[0].Rows[0]["YBCLDJXH"].ToString() != "")
                {
                    model.YBCLDJXH = Convert.ToDecimal(ds.Tables[0].Rows[0]["YBCLDJXH"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PTYBCL"] != null && ds.Tables[0].Rows[0]["PTYBCL"].ToString() != "")
                {
                    model.PTYBCL = Convert.ToDecimal(ds.Tables[0].Rows[0]["PTYBCL"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DJCLCB"] != null && ds.Tables[0].Rows[0]["DJCLCB"].ToString() != "")
                {
                    model.DJCLCB = Convert.ToDecimal(ds.Tables[0].Rows[0]["DJCLCB"].ToString());
                }
                if (ds.Tables[0].Rows[0]["GDFY"] != null && ds.Tables[0].Rows[0]["GDFY"].ToString() != "")
                {
                    model.GDFY = Convert.ToDecimal(ds.Tables[0].Rows[0]["GDFY"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ZJF"] != null && ds.Tables[0].Rows[0]["ZJF"].ToString() != "")
                {
                    model.ZJF = Convert.ToDecimal(ds.Tables[0].Rows[0]["ZJF"].ToString());
                }
                if (ds.Tables[0].Rows[0]["QTBDFY"] != null && ds.Tables[0].Rows[0]["QTBDFY"].ToString() != "")
                {
                    model.QTBDFY = Convert.ToDecimal(ds.Tables[0].Rows[0]["QTBDFY"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DJCB"] != null && ds.Tables[0].Rows[0]["DJCB"].ToString() != "")
                {
                    model.DJCB = Convert.ToDecimal(ds.Tables[0].Rows[0]["DJCB"].ToString());
                }
                if (ds.Tables[0].Rows[0]["YY"] != null && ds.Tables[0].Rows[0]["YY"].ToString() != "")
                {
                    model.YY = Convert.ToDecimal(ds.Tables[0].Rows[0]["YY"].ToString());
                }
                if (ds.Tables[0].Rows[0]["JDDS"] != null && ds.Tables[0].Rows[0]["JDDS"].ToString() != "")
                {
                    model.JDDS = Convert.ToDecimal(ds.Tables[0].Rows[0]["JDDS"].ToString());
                }
                if (ds.Tables[0].Rows[0]["JDDS1"] != null && ds.Tables[0].Rows[0]["JDDS1"].ToString() != "")
                {
                    model.JDDS1 = Convert.ToDecimal(ds.Tables[0].Rows[0]["JDDS1"].ToString());
                }
                if (ds.Tables[0].Rows[0]["JD"] != null && ds.Tables[0].Rows[0]["JD"].ToString() != "")
                {
                    model.JD = Convert.ToDecimal(ds.Tables[0].Rows[0]["JD"].ToString());
                }
                if (ds.Tables[0].Rows[0]["JDSK"] != null && ds.Tables[0].Rows[0]["JDSK"].ToString() != "")
                {
                    model.JDSK = Convert.ToDecimal(ds.Tables[0].Rows[0]["JDSK"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SKHD2"] != null && ds.Tables[0].Rows[0]["SKHD2"].ToString() != "")
                {
                    model.SKHD2 = Convert.ToDecimal(ds.Tables[0].Rows[0]["SKHD2"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CLLTF"] != null && ds.Tables[0].Rows[0]["CLLTF"].ToString() != "")
                {
                    model.CLLTF = Convert.ToDecimal(ds.Tables[0].Rows[0]["CLLTF"].ToString());
                }
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"SELECT ID,JH,SJRQ,SGFS,LX,JS,XM,DX,QX,ZYLQX,FHLX,JSLX,DJSR,SKHD,DS,DDJ,DJE,DJESZ,QC,QDJ,QC2,QDJ2,QJE,QJESZ,JCQC,JCQDJ,JCQJE,QDHJJE,JCQJESZ,BZQCDJXH,YBCLDJXH,PTYBCL,DJCLCB,GDFY,ZJF,QTBDFY,DJCB,YY,JDDS,JDDS1,JD,JDSK,SKHD2,CLLTF 
					FROM TB_DJSKCB ");
            strSql.Append(" where 1 = 1 ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" and " + strWhere);
            }
            return DbHelperOra.Query(strSql.ToString());
        }

        /// <summary>
        /// 获取记录总数
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) FROM TB_DJSKCB ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperOra.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }


        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.JH desc");
            }
            strSql.Append(")AS Row, T.*  from TB_DJSKCB T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperOra.Query(strSql.ToString());
        }

        /// <summary>
        /// 获取射孔工艺数据表中的井号
        /// </summary>
        /// <returns>井号</returns>
        public DataSet getSKGYSJBJH()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"SELECT ID,JH FROM skgysjb ");
            return DbHelperOra.Query(strSql.ToString());
        }

        #endregion  成员方法



        
    }
}

